const path = require('path');
const rootDir = path.resolve(__dirname, '../../')
console.log(rootDir)
module.exports = {
  verbose: true,
  testURL: 'http://localhost/',
  rootDir,
  moduleFileExtensions: [
    'js',
    'json',
    'vue'
  ],
  moduleNameMapper: {
    // "^@/(.*)$": "<rootDir>/src/$1", // 支持源代码中相同的 `@` -> `src` 别名
    '^@\/(.*?\.?(js|vue)?|)$': '<rootDir>/src/$1',   // @路径转换，例如：@/components/Main.vue -> rootDir/src/components/Main.vue
    // "^locales(.*)$": "<rootDir>/src/locales/$1", // You missed out `/` before the rest value `$1`
    '\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$': '<rootDir>/test/unit/__mocks__/fileMock.js', // 模拟加载静态文件
    '\\.(css|less|stylus)$': '<rootDir>/test/unit/__mocks__/styleMock.js'　　// 模拟加载样式文件
  },
  testMatch: [ //匹配测试用例的文件
    '<rootDir>/test/unit/specs/*.spec.js'
  ],
  transform: {
    '^.+\\.js$': '<rootDir>/node_modules/babel-jest',
    '.*\\.(vue)$': '<rootDir>/node_modules/vue-jest',
    // '^.+\\.(ts|tsx|js|jsx)?$': 'babel-jest'
  },
  testPathIgnorePatterns: [
    '<rootDir>/test/e2e'
  ],
  setupFiles: ['<rootDir>/test/unit/setup.js'],
  snapshotSerializers: ['jest-serializer-vue'],
  transformIgnorePatterns: ['<rootDir>/node_modules/'],
  coverageDirectory: '<rootDir>/test/unit/coverage', // 覆盖率报告的目录
  collectCoverageFrom: [ // 测试报告想要覆盖那些文件，目录，前面加！是避开这些文件
    // 'src/components/**/*.(js|vue)',
    'src/components/*.(vue)',
    '!src/main.js',
    '!src/router/index.js',
    '!**/node_modules/**'
  ],
  testEnvironment: "jsdom",

  // CSS options
  // experimentalCSSCompile: Boolean, // Default true.Turn off CSS compilation
  // hideStyleWarn: Boolean, // Default false.Hide warnings about CSS compilation
  // "globals": {
  //   "vue-jest": {
  //     "hideStyleWarn": true, // Change to true. show warnings about CSS compilation
  //     "experimentalCSSCompile": true,
  //   }
  // }
}